from jobs.sql_mehods import *
import pandas as pd
db = MySQLHelper(host='mmservice-05.mysql.hotgrid.cn', port=3306,
                 user='electricity_api_service', password='GJlfh7&#jg',
                 db='electricity_data', charset='utf8')
db2 = MySQLHelper(
    host='10.20.7.227',
    user='electricity_data',
    password='EF2zUl1GHss3yqay',
    db='electricity_data',
    port=33176,
    charset='utf8'
)

from datetime import datetime,timedelta

power_time= (datetime.now() - timedelta(days=30)).strftime('%Y-%m-&d %H:%M:%S')


power_sql= f"""select * from elec_dev_info where rated_power is null and
created_at >= '{power_time}'"""

# 查询当前的空的阈值的guidlist 最终用于监控他们最近是否产生对应的vlaue 5min数据
data=db.execute_charts(power_sql)



dev_code_list="'"+"','".join(data['dev_code'])+"'"

print(dev_code_list)

guid_lsit_sql = f"""
select distinct guid from elecdata_basic_info where dev_code in ({dev_code_list}) and data_type_id=8"""

dev_guid_list = db.execute_charts(guid_lsit_sql)
print(dev_guid_list)
print(len(data['dev_code']))
print(len(dev_guid_list['guid']))


# 依次循环取其对应的阈值补上
# 查看某个guid对应一个月的5m数据

















